package it.nesimuge.score.gui.model;

import it.lapomuge.db.entity.Atleta;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

public class ModelAtleti extends AbstractTableModel {

	List<Atleta> list = new ArrayList<Atleta>();

	@Override
	public int getColumnCount() {
		return 4;
	}

	@Override
	public int getRowCount() {
		return list.size();
	}

	@Override
	public Object getValueAt(int row, int colonna) {

		Atleta a = list.get(row);

		switch (colonna) {
		case 0:
			return (a.getId() != null ? a.getId() : null);
		case 1:
			return a.getCognome();
		case 2:
			return a.getNome();
		case 3:
			return a.getSocieta();
		}
		return null;
	}

	public void setList(List<Atleta> list) {
		this.list = list;
		this.fireTableDataChanged();
	}
	
	public List<Atleta> getList() {
		return list;
	}

}
